<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://unpkg.com/vue@next"></script>
</head>

<body>
    <div id="app"></div>
</body>
<script>
    let vm = {
        template: `
                    <child></child>
                `,
        setup () {
            const { ref, provide } = Vue
            let name = ref('GalaxySa')
            provide("name", name)
            provide('changeName', (value) => {
                name.value = value
            })
        }
    }
    let app = Vue.createApp(vm)
    app.component('child', {
        setup () {
            const { inject } = Vue
            let name = inject('name')
            let changeName = inject('changeName')
            let handler = () => {
                changeName('SliverTrain')
            }
            return { name, handler }
        },
        template: `
                    <div @click="handler">{{name}}</div>
                `,
    })
    app.mount('#app')
</script>

</html>